<template>
  <div class="_wz_cent_main _wz_trainList">
    <Card dis-hover :bordered="true" style="margin:0 0 10px;">
      <p slot="title">搜索</p>
      <Form :model="userSearch" label-position="right" :label-width="100" inline>
        <FormItem label="从业人员">
          <i-select v-model="userSearch.driverType" filterable placeholder="请选择从业类型" clearable>
            <Option v-for="item in personType" :value="item.code" :key="item.code">{{ item.value }}</Option>
          </i-select>
        </FormItem>
        <FormItem label="完成状态">
          <i-select v-model="userSearch.finishState" filterable placeholder="请选择完成状态" clearable>
            <Option value="0">未开始</Option>
            <Option value="1">及格</Option>
            <Option value="2">不及格</Option>
          </i-select>
        </FormItem>
        <Button type="primary" @click="userSearchFun">搜索</Button>
      </Form>
    </Card>
    <div>
      <wzTbale ref="wzTbale" :tableData="tableData"></wzTbale>
    </div>
    <Spin size="large" fix v-if="spinShow"></Spin>
  </div>
</template>
<script>
  import wzTbale from "../../../components/table/table";

  export default {
    components: {
      wzTbale,//列表
    },
    props:["selectData"],
    data() {
      return {
        userSearch:{examPlanUuid:this.selectData.uuid},
        personType: [],//从业类型
        spinShow:false,//本页加载
        tableData: {
          url: this.apiUrl.webApi + "/educate/examPlan/examStudentPlanList",//请求地址
          method: 'post',//请求方式
          where: {examPlanUuid:this.selectData.uuid},//搜索条件
          height: 'auto',//表格高度 auto
          page: false,//分页是否使用
          columns: [//表头数据
            {type: 'index', width: 70, align: 'center', title: '序号'},
            {title: '从业人员', key: 'driverName', minWidth: 100},
            {title: '从业类型', key: 'driverTypeName', minWidth: 100},
            {title: '驾乘车辆', key: 'driverVehicleNo', minWidth: 100},
            {title: '身份证号', key: 'driverIdentifyNum', minWidth: 160},
            {title: '联系电话', key: 'driverPhone', minWidth: 120},

            // {
            //   title: '考试次数', key: 'examStudentScore', minWidth: 120, render: (h, params) => {
            //     return h('div', params.row.examStudentCount + "次");
            //   }
            // },
            {
              title: '考试得分', key: 'examStudentScore', minWidth: 100, render: (h, params) => {
                return h('div', params.row.examStudentScore + "分");
              }
            },
            // {
            //   title: '及格分数', key: 'examStudentPassScore', minWidth: 120, render: (h, params) => {
            //     return h('div', params.row.examStudentPassScore + "分");
            //   }
            // },
            // {
            //   title: '考题总分', key: 'examStudentTotalScore', minWidth: 120, render: (h, params) => {
            //     return h('div', params.row.examStudentTotalScore + "分");
            //   }
            // },
            {
              title: '考试用时', key: 'examStudentUseDuration', minWidth: 100, render: (h, params) => {
                return h('div', parseInt(params.row.examStudentUseDuration / 60) +' 分钟 '+ params.row.examStudentUseDuration % 60 +' 秒');
              }
            },
            {
              title: '考试情况', minWidth: 130, render: (h, params) => {
                return h('Tag', {
                  props: {
                    type: 'dot',
                    color: (params.row.examStudentPass == 0) ? "" : (params.row.examStudentPass == 1) ? "success" : "warning"
                  }
                }, (params.row.examStudentPass == 0) ? "未开始" : (params.row.examStudentPass == 1) ? "考试及格" : "不及格");
              }
            },
          ],
          format: {//返回数据格式
            list: ['data'],//数据list
          },
        },
      }
    },
    computed: {//计算属性

    },
    beforeCreate() {//beforeCreate创建前状态

    },
    created() {//created创建完毕状态

    },
    beforeMount() {//beforeMount挂载前状态   DOM 元素然后塞入页面的过程

    },
    mounted() {//mounted 挂载结束状态
      let that = this;

      //加载从业类型字典
      that.axios.post(that.apiUrl.systemDictSystemDictList, {type: 'person_type'}).then(res => {
        if (!!res) {
          that.personType = res.data.data;
        }
      }).catch(err => {
        console.log("失败", err)
      })

    },
    methods: {//执行的方法
      userSearchFun(){
        this.tableData.where = JSON.parse(JSON.stringify(this.userSearch));
        this.$refs.wzTbale.tableLoadData(true);
      },

    },
    watch: {//监听

    },
    beforeUpdate() {//beforeUpdate 更新前状态

    },
    updated() {//updated 更新完成状态

    },
    beforeDestroy() {//beforeDestroy 销毁前状态

    },
    destroyed() {//destroyed 销毁完成状态

    }
  }
</script>
<style lang="less">
  ._wz_trainList{
    width: 100%;
    height: 100%;
  }

</style>
